using dbvc.data;
using dbvc.Queries;

namespace dbvc.context.Security
{
    public static class Principal
    {
        public static bool isRoot(this db_user self)
        {
            return self.name == "root";
        }
    }

    public class Security
    {
        private db_user principal;

        public db_user Principal
        {
            get { return principal; }
        }

        public void Login(string usr, string pass)
        {
            principal = SecurityQuery.GetUser(usr, pass);
        }

        public void Logout()
        {
            principal = null;
        }

        public bool IsAuth()
        {
            return principal != null;
        }
    }
}